package pers.cz.commons.datasource;

/**
 * 数据源切换工具
 * @program: PostGirl-panent
 * @description: DbKeyHolder
 * @author: Cheng Zhi
 * @create: 2021-12-27 17:57
 **/
public class DbKeyHolder {

    public DbKeyHolder(String dbkey) {

        this.setDbKey(dbkey);
    }

    public static final String DATA_SOURCE_DEFAULT = "dataSourceA";

    public static final String DATA_SOURCE_B = "dataSourceB";

    public static final String oracle_DB = "oracle_db";

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static void setDbKey(String db_Key) {
        contextHolder.set(db_Key);
    }

    public static String getDbKey() {
        return contextHolder.get();
    }

    public static void clearDbKey() {
        contextHolder.remove();
    }
}
